package com.company.controller;

import com.company.bean.Student;
import com.company.service.impl.ServiceMapperImp;
import org.junit.Test;

import java.util.List;

public class ControllerStudent {
    private ServiceMapperImp serviceMapperImp = new ServiceMapperImp();
    @Test
    public void selectAll(){
        List<Student> students = serviceMapperImp.selectAll();
        System.out.println();
        for (Student student : students) {
            System.out.println(student);
        }
    }
    @Test
    public void selectByid(){
        Student student = serviceMapperImp.selectByid(2);
        System.out.println(student);
    }
    @Test
    public void insert(){
        Integer insert = serviceMapperImp.insert(new Student(8, "机器人7", 28));
        if (insert == 1){
            System.out.println("添加成功");
        }else {
            System.out.println("添加失败");
        }
    }
    @Test
    public void update(){
        Integer update = serviceMapperImp.update(new Student(2, "死吗伍鉴", 28));
        if (update == 1){
            System.out.println("修改成功");
        }else {
            System.out.println("修改失败");
        }
    }
    @Test
    public void delete(){
        Integer delete = serviceMapperImp.delete(2);
        if (delete == 1){
            System.out.println("删除成功");
        }else {
            System.out.println("删除失败");
        }
    }
}
